﻿using amis6_api.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Dapper;

namespace amis6_api.Utils
{
    public class UserPermissionUtil
    {
        public static string GetUserPermission(Guid userid)
        {
            using var conn = DbFactory.Db();
            List<string> tempGroup = new List<string> {userid.ToString()};
            var gids = conn.Query<Guid>($"select G_ID from t_Group_User where U_ID='{userid}'").ToList();
            if (gids.Count>0)
            {
                foreach (var item in gids)
                {
                    tempGroup.Add(item.ToString());
                }
            }
            StringBuilder uid=new StringBuilder("(");
            foreach (var item in tempGroup)
            {
                uid.Append($"'{item}',");
            }
            uid.Remove(uid.Length - 1, 1);
            uid.Append(")");
            return uid.ToString();
        }
    }
}
